package ru.megazlo.basemvc.controllers;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import ru.megazlo.basemvc.controllers.base.Action;
import ru.megazlo.basemvc.controllers.base.BaseController;
import ru.megazlo.basemvc.dto.view.NewsEdit;
import ru.megazlo.basemvc.service.NewsService;

import javax.servlet.http.HttpServletResponse;

@Controller
public class NewsController extends BaseController {

	@Autowired
	private NewsService newsService;

	@Action
	@RequestMapping(value = "/news/page/{num}", method = RequestMethod.GET)
	public Object getNewsPage(@PathVariable Integer num, HttpServletResponse response) {
		newsService.getNewsByPage(num);
		return getResult("message", "Body Content goes Here!", response);
	}

	@Action
	@RequestMapping(value = "/news/save", method = RequestMethod.POST)
	public void createNews(NewsEdit newItem) {

	}

	@Action
	@RequestMapping("/news/edit")
	public Object edit(HttpServletResponse response) {
		return getResult(response);
	}

	/*@Action
	@RequestMapping(value = "/news/edit/{id}", method = RequestMethod.POST)
	public void editNews(@PathVariable Long id) {

	}*/
}
